package modelo;

import javax.persistence.*;
import javax.servlet.*;

public class GuestListener implements ServletContextListener {
	 
    // Prepare the EntityManagerFactory & Enhance:
    public void contextInitialized(ServletContextEvent e) {        
        EntityManagerFactory emf =
            Persistence.createEntityManagerFactory("jyaa");
        e.getServletContext().setAttribute("emf", emf);
    }
 
    // Release the EntityManagerFactory:
    public void contextDestroyed(ServletContextEvent e) {
        EntityManagerFactory emf =
            (EntityManagerFactory)e.getServletContext().getAttribute("emf");
        emf.close();
    }
}
